# -*- coding: utf-8 -*-
from __future__ import absolute_import

import datetime
from scopt.util import sqlalchemy_util as db_util


def insert(connection, metadata):
    insert = db_util.insert_fn(connection, metadata)

##### SETUP CODETABLES ########################################################
    insert('m01_uom',
    [['id', 'desc_i18n'],
     [1, 'kg'],
     [2, u'pc/počet'],
     [3, 'l'],
     [4, 'm']])

    insert('m01_med_type',
    [['id', 'desc_i18n'],
     [1, 'email'],
     [2, u'mobile'],
     [3, 'skype']])

    insert('m01_whs',
    [['id', 'desc'],
     [1, u'Warehouse in New Jersey / Sklad v New Jersey'],
     [2, u'Warehouse in Banská Bystrica / Sklad v Banskej Bystrici']])

    insert('m01_add',
    [['id', 'line_1', 'city', 'zip', 'country'],
     [1, u'Janka Kráľa 8.', u'Banská Bystrica', '97404', 'Slovensko'],
     [2, 'Oxford street 12', 'New Jersey', '890579', 'USA']])

    insert('m01_add_type',
    [['id', 'desc_i18n'],
     [1, 'Warehouse/Sklad'],
     [2, u'Office/Kancelária'],
     [3, 'Home/Domov']])

    insert('m01_bp',
    [['id', 'desc'],
     [1, u'All Stuff Inc. / Všehochuť s.r.o.'],
     [2, 'SuperStore / Superobchod'],
     [3, u'Perfect customer / Perfektný zákazník']])

    insert('m01_s',
    [['id', 'bp_id'],
     [1, 1],
     [2, 2]])

    insert('m01_cust',
    [['id', 'bp_id'],
     [1, 3]])

##### SETUP VARIANTS ##########################################################
    insert('m01_p_va',
    [['id', 'desc_i18n'],
     [1, u'Blue - 36 / Modrá - 36'],
     [2, u'Red - 42 / Červená 42']])

    insert('m01_p_va_o',
    [['id', 'desc_i18n'],
     [1, 'Color / Farba'],
     [2, u'Bodywear Size / Veľkosť oblečenia']])

    insert('m01_p_va_ov',
    [['id', 'p_va_o_id', 'desc_i18n'],
     [1, 1, u'Red / Červená'],
     [2, 1, u'Blue / Modrá'],
     [3, 2, '36'],
     [4, 2, '42']])

    insert('m01_p_va_d',
    [['p_va_id', 'p_va_ov_id'],
     [1, 1],
     [1, 2],
     [2, 3],
     [2, 4]])

##### SETUP ITEMS #############################################################
    insert('m01_p',
    [['id', 'name', 'serializable', 'uom_id'],
     [1, 'Lee trousers / Lee nohavice', False, 2],
     [2, u'Big bunch of iron / Veľká hrča železa', False, 1],
     [3, u'Horton crossbow / Kuša Horton / Bone Collector', True, 2],
     [4, u'Paracord 550', False, 4]])

    insert('m01_i',
    [['id', 'p_id', 'sku', 'sn', 'va_id'],
     [1, 1, 'TR-LEE-BL36', None, 1],
     [2, 1, 'TR-LEE-RE42', None, 2],
     [3, 2, 'IR-BB-890', None, None],
     [4, 3, 'CB-HR-012-1234', 'SN-HO-CB-BC-1234', None],
     [5, 3, 'CB-HR-012-5678', 'SN-HO-CB-BC-5678', None],
     [6, 4, 'PC-550-1', None, None]])

##### SETUP ITEM IDENTIFIERS ##################################################
    insert('m01_i_ssku',
    [['i_id', 's_id', 'sku'],
     [1, 1, 'AS-LEE-BL36'],
     [2, 1, 'AS-LEE-RE42'],
     [3, 1, 'AS-IR'],
     [4, 1, 'AS-CB'],
     [5, 1, 'AS-CB'],
     [6, 1, 'AS-PC'],
     [6, 2, 'SS-PC']])

    insert('m01_i_didc_a',
    [['id', 'desc_i18n'],
     [1, 'BC']])

    insert('m01_i_didc_av',
    [['i_id', 'i_didc_a_id', 'didc_av'],
     [4, 1, 'INTL-BC-HOCB-1234'],
     [5, 1, 'INTL-BC-HOCB-5678']])

##### SETUP INVENTORY ITEM ####################################################
    insert('m01_ii',
    [['i_id', 'whs_id', 'qty'],
     [1, 2, 9],
     [1, 1, 4],
     [2, 2, 8],
     [3, 1, 1530],
     [4, 1, 1],
     [5, 1, 1],
     [6, 2, 0]])

    insert('m01_slq',
    [['id', 'i_id', 'whs_id', 'date_ob', 'qty_ob', 'qty_iss', 'qty_rec',
      'qty_adj'],
     [1, 1, 2, datetime.date(2012, 10, 1), 9, 0, 0, 0],
     [2, 1, 1, datetime.date(2012, 10, 1), 4, 0, 0, 0],
     [3, 2, 2, datetime.date(2012, 10, 1), 8, 0, 0, 0],
     [4, 3, 1, datetime.date(2012, 10, 1), 1530, 0, 0, 0],
     [5, 4, 1, datetime.date(2012, 10, 1), 1, 0, 0, 0],
     [6, 5, 1, datetime.date(2012, 10, 1), 1, 0, 0, 0],
     [7, 6, 2, datetime.date(2012, 10, 1), 0, 0, 0, 0]])

##### SETUP ADDRESSES #########################################################
    insert('m01_whs_add',
    [['id', 'whs_id', 'add_id', 'add_type_id', 'note'],
     [1, 1, 2, 1, 'warehouse in New Jersey / sklad v New Jersey'],
     [2, 2, 1, 1, 'warehouse in Banska Bystrica / sklad v Banskej Bystrici']])

    insert('m01_bp_add',
    [['id', 'bp_id', 'add_id', 'add_type_id', 'note'],
     [1, 1, 1, 2, u'office in Banska Bystrica / kancelária v Banskej Bystrici'],
     [2, 2, 2, 2, u'office in New Jersey / kancelária v New Jersey']])

##### SETUP MEDIA CONTATS #####################################################
    insert('m01_med_con',
    [['id', 'con_str'],
     [1, 'all_stuff@gmail.com'],
     [2, '421-902-222-222']])

    insert('m01_bp_med_con',
    [['id', 'bp_id', 'med_con_id', 'med_type_id', 'note'],
     [1, 1, 1, 1, u'office of All Stuff / kancelária Všehochuť'],
     [2, 1, 2, 2, u'office of All Stuff / kancelária Všehochuť']])
